 <g:if test="${search}">
 	<script>
		window.dhx_globalImgPath="../../images/imgs/";
	</script>
	<link rel="STYLESHEET" type="text/css" href="../../css/dhtmlxcombo.css">
 </g:if>
 <g:else>
 	<script>
			window.dhx_globalImgPath="../images/imgs/";
	</script>
	<link rel="STYLESHEET" type="text/css" href="../css/dhtmlxcombo.css">
 </g:else>
      
   <ol class="form form-clear error-form" style="margin-top:-15px">
     <%def today = new Date();
            today.setMonth(today.month-1);
            %>
   <!-- Lable Hàng 1 -->
   <li>
   	<label class="label-left" style="width:72px" for="fromDate">Từ ngày</label>
   	<label class="label-left"  style="width:72px" for="toDate">Đến ngày</label>
   	<label  class="label-left" style="width:115px" for="nguoigayloi">Kiểu ngày</label>
   	<label class="label-left" style="width:115px" for="NhomMucLoi1">Nhóm lỗi mức 1</label>
   	<label class="label-left" style="width:115px" for="NhomMucLoi2">Nhóm lỗi mức 2</label>
   	<label class="label-left" style="width:100px" for="NhomMucLoi3">Nhóm lỗi mức 3</label>   	      
   </li>   
   <li class="allTop">
   		<input style="width:65px" name="fromDate" id="fromDate" class=" datetime" value="${params.fromDate?params.fromDate:DateUtil.formatDate(today)}" readonly="readonly"/></label>
   		<input name="toDate" id="toDate" style="width:65px" class=" datetime" value="${params.toDate?params.toDate:DateUtil.formatDate(new Date())}" readonly="readonly"/></label>
   			
   		<select name="KieuNgay" style="width:120px">
			<option value="1" ${kieuNgay=='1'?'selected="true"':'' }>1-Ngày xảy ra</option>
			<option value="2" ${kieuNgay=='2'?'selected="true"':'' }>2-Thời hạn khắc phục</option>
			<option value="3" ${kieuNgay=='3'?'selected="true"':'' }>3-Thời gian nhập hệ thống</option>
				  
		</select>
		<g:select style="width:120px" name="LoiCap1" id="LoiCap1" from="${allErrorList1}"
							optionKey="id" optionValue="${{it.name} }" noSelection="${['':'']}"							
							value="${LoiCap1}" /> 
<%--							allErrorList2--%>
   	    <g:select style="width:120px" name="LoiCap2" id="LoiCap2" from="${}" optionKey="id" 
   	    					\ optionValue="${{it.name} }"
   	     					noSelection="${['':'']}" />
<%--   	    allErrorList3--%>
   	    <g:select name="LoiCap3" id="LoiCap3" style="width:120px" from="${}"
							optionKey="id" optionValue="${{it.name }}" noSelection="${['':'']}"\ />   
   	    	
<%--		<g:select name="LoiCap3" id="LoiCap3" style="width:120px" from="${allErrorList3}"--%>
<%--							optionKey="id" />--%>
		<g:submitButton class="searchButtons btn primary" style="margin-left:0px;margin-top:0px;width:100px" name="search" value="Lọc thông tin" />
	</li>
<!-- Lable Hàng 2 -->
   <li>
   		<label class="label-left" style="width:152px" for="NHCD">NHCD/Khối Nhập</label>
   		<label class="label-left" style="width:115px" for="CN">CN/Trung tâm nhập</label>
   		<label class="label-left" style="width:118px" for="PGD">PGD/Tổ/Nhóm nhập</label>
   		<label class="label-left" style="width:115px" for="HTPH">Hình thức phát hiện</label>
   		<label class="label-left" style="width:115px" for="LoaiNghiepVu">Loại nghiệp vụ</label>
   		<label class="label-left" style="width:80px" for="NguoiNhap">User nhập</label>
   		
 	
  </li> 
  		
   <li class="allTop">
   		<g:select style="width:155px" name="NHCD" id="NHCD" from="${allDonViNhap1}"
							value="${tenDonVi1 }" optionKey="id" optionValue="${{it.name }}" noSelection="${['':'']}" />
<%--							allDonViNhap2--%>
  		<g:select  name="CN" id="CN" style="width:120px" from="${}"
  				 optionKey="id" optionValue="${{it.name }}"  noSelection="${['':'']}" />			
<%--allDonViNhap3--%>
   		<g:select name="PGD" id="PGD" style="width:120px" from="${}"  optionKey="id" optionValue="${{it.name }}" noSelection="${['':'']}"/>
     	<g:select style="width:120px" name="HTPH" from="${allErrorCheck}"
							optionKey="id" optionValue="${{it.name}}" noSelection="${['':'']}" value="${erroCheck}" />
		<g:select style="width:120px" name="LoaiNghiepVu" value = "${LoaiNghiepVu }" id="LoaiNghiepVu" from="${allbusiness}"
							optionKey="id" optionValue="${{it.code+'-'+it.name}}" noSelection="${['':'']}"/>	
   		<input type="text" name="NguoiNhap" style="width:90px" value="${NguoiNhap}">
   </li>
<!-- Lable Hàng3 -->   	
   <li>
   		<label class="label-left" style="width:152px" for="NHCDLoi">NHCD/Khối lỗi</label>
   		<label class="label-left" style="width:115px" for="CNLoi">CN/Trung tâm lỗi</label>
   		<label class="label-left" style="width:115px" for="PGDLoi">PGD/Tổ/Nhóm lỗi</label>
   		<label class="label-left" style="width:115px" for="NguoiGayLoi">User lỗi</label>
   		<label class="label-left" style="width:115px" for="TrangThai">Trạng thái</label>   			
   		<label class="label-left" style="width:80px" for="IdNhanSu">ID nhân sự</label>
   </li>
   <li class="allTop">   		   
   		<g:select style="width:155px" name="NHCDLoi" id= "NHCDLoi" from="${allDonViLoi1}" 
							value="${DonViLoi1}" optionKey="id" optionValue="${{it.name} }" noSelection="${['':'']}" />						
<%--   		allDonViLoi2--%>
   		<g:select name="CNLoi" id="CNLoi" from="${}" 
   				optionKey="id"  optionValue="${{it.name}}"  noSelection="${['':'']}" style="width:120px"/>
<%--   		allDonViLoi3--%>
   		<g:select  name="PGDLoi" id="PGDLoi" style="width:120px" from="${}"  
   	      					optionKey="id" optionValue="${{it.name}}" noSelection="${['':'']}" />
   		
   		 
   		
   		
   		<input type="text" name="NguoiGayLoi" style="width:110px" value="${NguoiGayLoi }" />		
		<g:select style="width:120px" name="TrangThai" value="${TrangThai }" id="TrangThai" from="${allErrorStatus}"
							optionKey="id" optionValue="${{it.code+'-'+it.nameStatus}}" noSelection="${['':'']}"/>
	 
		<input type="text" name="IdNhanSu" style="width:90px" value="${IdNhanSu}">	
   </li>		
 
   </ol>
   
 
 
 		<script type="text/javascript">
 		var l3=dhtmlXComboFromSelect("LoiCap3");
 		l3.enableFilteringMode(true);
 		var l2=dhtmlXComboFromSelect("LoiCap2");
 		l2.enableFilteringMode(true);
 		var l1=dhtmlXComboFromSelect("LoiCap1");
 		l1.enableFilteringMode(true);
 		l1.attachEvent("onChange", onChangeFunc1);
 		l2.attachEvent("onChange", onChangeFunc2);


 		function onChangeFunc1() {
 			<%--	        	  alert(3);--%>
 					  if(!l1.getSelectedText()){
 						  	l2.clearAll();	
 						  	l3.clearAll();	
 				      }
 					  $("#LoiCap3").val("");
 					  $("#LoiCap2").val(""); 
 					  if(l1.getSelectedValue()){
 						  $.getJSON('${createLink(controller:'opError',action:'getErrorList2')}?parent_id='+l1.getSelectedValue(),function(unitDepart2){
 							  l2.clearAll();
 								for(var i=0;i<unitDepart2.length;i++)
 								{		
 									 
 									l2.addOption(""+unitDepart2[i].id+"",""+unitDepart2[i].name.trim()+"");											 
 								}	
 						});												
 					   }
 					   		
 					    return true;
 					};
 				  function onChangeFunc2() {
 				<%--    		          	  alert(z2.getSelectedValue());--%>
 						if(!l2.getSelectedText()){					 
 							l3.clearAll();		
 						} 
 						$("#LoiCap3").val("");
 					    if(l2.getSelectedValue()){
 					    	$.getJSON('${createLink(controller:'opError',action:'getErrorList2')}?parent_id='+l2.getSelectedValue(),function(unitDepart3){
 						    l3.clearAll();
 				    	    for(var i=0;i<unitDepart3.length;i++)
 				    	    {	
 				    	    	l3.addOption(""+unitDepart3[i].id+"",""+unitDepart3[i].name.trim()+"");											 
 				    	    }													
 				    	      			
 				    	    });											
 					  	}
 					  	    	   		
 					    return true;
 					};
 			 		if(l1.getSelectedValue()&&!l2.getSelectedValue()){
 			 			alert("search");
 			 			$.getJSON('${createLink(controller:'opError',action:'getErrorList2')}?parent_id='+l1.getSelectedValue(),function(unitDepart2){
 			 							  l2.clearAll();
 			 								for(var i=0;i<unitDepart2.length;i++)
 			 								{		
 			 									l2.addOption(""+unitDepart2[i].id+"",""+unitDepart2[i].name.trim()+"");											 
 			 								}	
 			 					l2.setComboValue(""+${LoiCap2?LoiCap2:' '}+"");   
 			 					if(l2.getSelectedValue()&&!l3.getSelectedValue()){
 			 						$.getJSON('${createLink(controller:'opError',action:'getErrorList2')}?parent_id='+l2.getSelectedValue(),function(unitDepart3){
 			 						    l3.clearAll();
 			 				    	    for(var i=0;i<unitDepart3.length;i++)
 			 				    	    {	
 			 				    	    	l3.addOption(""+unitDepart3[i].id+"",""+unitDepart3[i].name.trim()+"");											 
 			 				    	    }												
 			 				    	    l3.setComboValue(""+${LoiCap3?LoiCap3:' '}+"");   			
 			 				    	    });
 			 					}	
 			 			});
 			 		}
/*-------------------------------*/		
var z3=dhtmlXComboFromSelect("PGD");
 			 		z3.enableFilteringMode(true);
 			 		var z2=dhtmlXComboFromSelect("CN");
 			 		z2.enableFilteringMode(true);
 			 		var z1=dhtmlXComboFromSelect("NHCD");
 			 		z1.enableFilteringMode(true);
 			 		z2.attachEvent("onChange", onChangeFunc4);
 			 		z1.attachEvent("onChange", onChangeFunc3);
 			 		if(z1.getSelectedValue()&&!z2.getSelectedValue()){
 			 			$.getJSON('${createLink(controller:'opError',action:'getUnitDepart2')}?parent_id='+z1.getSelectedValue(),function(unitDepart2){
 			 				z2.clearAll();
 			 					for(var i=0;i<unitDepart2.length;i++)
 			 					{			
 			 							z2.addOption(""+unitDepart2[i].id+"",""+unitDepart2[i].name.trim()+"");											 
 			 					}
 			 					z2.setComboValue(""+${tenDonVi2?tenDonVi2:' '}+"");
 			 					
 			 					if(z2.getSelectedValue()&&!z3.getSelectedValue()){
 			 						$.getJSON('${createLink(controller:'opError',action:'getUnitDepart2')}?parent_id='+z2.getSelectedValue(),function(unitDepart3){
 			 							z3.clearAll();
 			 				    	    for(var i=0;i<unitDepart3.length;i++)
 			 				    	    {	
 			 				    	      	z3.addOption(""+unitDepart3[i].id+"",""+unitDepart3[i].name.trim()+"");											 
 			 				    	    }													
 			 				    	    z3.setComboValue(""+${tenDonVi3?tenDonVi3:' '}+"");  			
 			 				    	    });
 			 					}	
 			 			});
 			 		}
 			 		function onChangeFunc3() {
 			 			<%--	        	  alert(3);--%>
 			 					  if(!z1.getSelectedText()){
 			 							z2.clearAll();	
 			 							z3.clearAll();	
 			 				      }
 			 					  $("#PGD").val("");
 			 					  $("#CN").val(""); 
 			 					  if(z1.getSelectedValue()){
 			 						  $.getJSON('${createLink(controller:'opError',action:'getUnitDepart2')}?parent_id='+z1.getSelectedValue(),function(unitDepart2){
 			 							z2.clearAll();
 			 			<%--					alert(unitDepart2);--%>
 			 								for(var i=0;i<unitDepart2.length;i++)
 			 								{			
 			 										z2.addOption(""+unitDepart2[i].id+"",""+unitDepart2[i].name.trim()+"");											 
 			 								}	
 			 						});												
 			 					   }
 			 					   		
 			 					    return true;
 			 					} 
 			 				  function onChangeFunc4() {
 			 				<%--    		          	  alert(z2.getSelectedValue());--%>
 			 						if(!z2.getSelectedText()){					 
 			 							z3.clearAll();		
 			 						} 
 			 						$("#PGD").val("");
 			 					    if(z2.getSelectedValue()){
 			 					    	$.getJSON('${createLink(controller:'opError',action:'getUnitDepart2')}?parent_id='+z2.getSelectedValue(),function(unitDepart3){
 			 						    z3.clearAll();
 			 				    	    for(var i=0;i<unitDepart3.length;i++)
 			 				    	    {	
 			 				    	      	z3.addOption(""+unitDepart3[i].id+"",""+unitDepart3[i].name.trim()+"");											 
 			 				    	    }													
 			 				    	      			
 			 				    	    });											
 			 					  	}
 			 					  	    	   		
 			 					    return true;
 			 					}
/*-------------------------------------------*/
 			 				var z6=dhtmlXComboFromSelect("PGDLoi");
 			 				z6.enableFilteringMode(true);
 			 				var z5=dhtmlXComboFromSelect("CNLoi");
 			 				z5.enableFilteringMode(true);
 			 				var z4=dhtmlXComboFromSelect("NHCDLoi");
 			 				z4.enableFilteringMode(true);
 			 				z5.attachEvent("onChange", onChangeFunc6);
 			 				z4.attachEvent("onChange", onChangeFunc5);
 			 				if(z4.getSelectedValue()&&!z5.getSelectedValue()){
 	 			 				alert(${tenDonVi2Loi});
 			 					$.getJSON('${createLink(controller:'opError',action:'getUnitDepart2')}?parent_id='+z4.getSelectedValue(),function(unitDepart2){
 			 						z5.clearAll();
 			 							for(var i=0;i<unitDepart2.length;i++)
 			 							{			
 			 									z5.addOption(""+unitDepart2[i].id+"",""+unitDepart2[i].name.trim()+"");											 
 			 							}
 			 							z5.setComboValue(""+${DonViLoi2?DonViLoi2:' '}+"");
 			 							
 			 							if(z5.getSelectedValue()&&!z6.getSelectedValue()){
 			 								$.getJSON('${createLink(controller:'opError',action:'getUnitDepart2')}?parent_id='+z5.getSelectedValue(),function(unitDepart3){
 			 									z6.clearAll();
 			 						    	    for(var i=0;i<unitDepart3.length;i++)
 			 						    	    {	
 			 						    	      	z6.addOption(""+unitDepart3[i].id+"",""+unitDepart3[i].name.trim()+"");											 
 			 						    	    }													
 			 						    	    z6.setComboValue(""+${DonViLoi3?DonViLoi3:' '}+"");  			
 			 						    	    });
 			 							}	
 			 					});
 			 				}
 			 				function onChangeFunc5() {
 			 					<%--	        	  alert(3);--%>
 			 							  if(!z4.getSelectedText()){
 			 									z2.clearAll();	
 			 									z3.clearAll();	
 			 						      }
 			 							  $("#PGDLoi").val("");
 			 							  $("#CNLoi").val(""); 
 			 							  if(z4.getSelectedValue()){
 			 								  $.getJSON('${createLink(controller:'opError',action:'getUnitDepart2')}?parent_id='+z4.getSelectedValue(),function(unitDepart2){
 			 									z5.clearAll();
 			 					<%--					alert(unitDepart2);--%>
 			 										for(var i=0;i<unitDepart2.length;i++)
 			 										{			
 			 												z5.addOption(""+unitDepart2[i].id+"",""+unitDepart2[i].name.trim()+"");											 
 			 										}	
 			 								});												
 			 							   }
 			 							   		
 			 							    return true;
 			 							} 
 			 						  function onChangeFunc6() {
 			 						<%--    		          	  alert(z2.getSelectedValue());--%>
 			 								if(!z5.getSelectedText()){					 
 			 									z6.clearAll();		
 			 								} 
 			 								$("#PGDLoi").val("");
 			 							    if(z5.getSelectedValue()){
 			 							    	$.getJSON('${createLink(controller:'opError',action:'getUnitDepart2')}?parent_id='+z5.getSelectedValue(),function(unitDepart3){
 			 								    z6.clearAll();
 			 						    	    for(var i=0;i<unitDepart3.length;i++)
 			 						    	    {	
 			 						    	      	z6.addOption(""+unitDepart3[i].id+"",""+unitDepart3[i].name.trim()+"");											 
 			 						    	    }													
 			 						    	      			
 			 						    	    });											
 			 							  	}
 			 							  	    	   		
 			 							    return true;
 			 							}
	</script>